import {defineStore} from 'pinia';

const store = {
    id: "dict",
    state(){
        return {

        }
    },

    getters: {
        /**
         * 角色列表
         * @returns {(function(): Promise<[]|*[]|undefined>)|*}
         * @constructor
         */
        ROLE_LIST() {
            return async ()=> {
                let {data} = await Http.get("/role/list", {status: 0});

                let dataList = []
                if (! Helper.emptyArray(data)) {
                    data.forEach(i => {
                        dataList.push({label: i.roleName, value: i.roleId})
                    })
                }
                return dataList;
            }
        },
        /**
         * 渠道列表
         * @returns {(function(): Promise<[]|*[]|undefined>)|*}
         * @constructor
         */
        TENANT_LIST() {
            return async ()=> {
                let {data} = await Http.get("/tenant/list", {status: 0});

                let dataList = []
                if (! Helper.emptyArray(data)) {
                    data.forEach(i => {
                        dataList.push({label: i.name, value: i.id})
                    })
                }
                return dataList;
            }
        },
    },

    actions: {
        async get(options, query, cache) {
            let {code, data} = await Http.get("/dict/type/" + options);
            return data;
        }
    }
}

export default defineStore(store)


